package com.cwt_taxi_xa.custom_view;

import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cwt_taxi_xa.R;
import com.cwt_taxi_xa.protocol.can.IViewAirCondition;
import com.cwt_taxi_xa.util.AppLog;


/**
 * Created by ZY on 2016/8/10.
 * 底部菜单栏
 */
public class FloatAirCondition extends LinearLayout implements IViewAirCondition{
	String TAG = "FloatAirCondition";
	public int width = 350;
	public int height = 100;

	TextView tvTemperature,tvTemperatureUnit;
	ImageView ivOutMode;
	AirConditionView mAirConditionView;


	public FloatAirCondition(final Context context) {
		super(context);
		View root = View.inflate(context, R.layout.float_conditioning, null);
		addView(root);
		initView(root);
	}

	private void  initView(View root){
		tvTemperature = (TextView)root.findViewById(R.id.tv_float_window_temperature);
		tvTemperatureUnit = (TextView)root.findViewById(R.id.tv_float_window_temperature_unit);
		mAirConditionView = (AirConditionView)root.findViewById(R.id.iv_outlet_mode);
		ivOutMode = (ImageView)root.findViewById(R.id.iv_out_mode);
		Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "LEDFONT.ttf");
		tvTemperature.setTypeface(typeface);
	}

	@Override
	public void heaterType(int heaterType) {

	}

	@Override
	public void heatingMode(int heatingMode) {

	}

	@Override
	public void windLevel(int level) {
		// TODO Auto-generated method stub
		mAirConditionView.selectLevel(level);
	}

	@Override
	public void outletMode(int type) {
		// TODO Auto-generated method stub
		ivOutMode.setImageLevel(type);
	}

	@Override
	public void showTemperature(String temp) {
		tvTemperature.setText(temp);
	}

	@Override
	public void showTemperatureUnit(String unit) {
		tvTemperatureUnit.setText(unit);
	}

	@Override
	public void errorCode(int code) {
		// TODO Auto-generated method stub
		if(1 == code){
			tvTemperatureUnit.setVisibility(View.VISIBLE);
			AppLog.d(TAG,"errorCode 不显示!");
		}if (2 == code){//显示错误码
			AppLog.d(TAG,"errorCode 显示!");
			tvTemperatureUnit.setVisibility(View.INVISIBLE);
		}
	}

	@Override
	public void power(int type) {
		// TODO Auto-generated method stub

	}
}
